package com.whg.demo.biz.ureport.datasource;

import com.bstek.ureport.definition.datasource.BuildinDatasource;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

/**
 * @Author whg
 * @create 2023/3/15 15:47
 * @description：
 */
@Component
public class XdclassBuildinDatasource implements BuildinDatasource {

    private DataSource dataSource;

    public XdclassBuildinDatasource(@Qualifier("xdclass") DataSource dataSource) {
        this.dataSource = dataSource;
    }

    @Override
    public String name() {
        return "内置数据源xdclass";
    }

    @Override
    public Connection getConnection() {
        try {
            return dataSource.getConnection();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
